/**
 * <p>
 * 表格配置
 *
 * @Author：Roy
 * @Description：预警
 * @Date：Create by 2023-12-04 14:51:04
 */
// 隐藏操作按钮的规则配置，字段名：isEdit
// const isHidden = (list, row) => {
//   const { isEdit } = row || {}
//   return list.includes(String(isEdit))
// }

const headerConfig = {
  'early-warning': [
    {
      prop: 'warningName',
      name: '预警名称',
      minWidth: 110
    },
    {
      prop: 'projectName',
      name: '所属项目',
      minWidth: 100
    },
    {
      prop: 'sceneInfoName',
      name: '所属场景',
      minWidth: 110
    },
    {
      prop: 'deviceName',
      name: '关联设备',
      minWidth: 110
    },
    {
      prop: 'energyTypeName',
      name: '能源类型',
      minWidth: 90
    },
    {
      prop: 'meterConditionName',
      name: '计量条件',
      minWidth: 90
    },
    {
      prop: 'pushTypeName',
      name: '推送规则',
      minWidth: 90
    },
    {
      prop: 'endTime',
      name: '预警阈值及预警级别',
      minWidth: 160,
      formatter: (row, item) => {
        const { warningThresholds } = row
        let str = ''
        if (warningThresholds && warningThresholds.length) {
          warningThresholds.forEach(item => {
            str += item.judgeRuleName + item.thresholdValue + ':' + item.thresholdLevelName + '<br/>'
          })
        }
        return str
      }
    },
    {
      prop: 'startTime',
      name: '生效时间',
      minWidth: 210,
      formatter: (row, item) => {
        return '开始：' + row.startTime + ' <br/> 结束：' + row.endTime
      }
    },
    // {
    //   prop: 'endTime',
    //   name: '结束时间',
    //   minWidth: 110
    // },
    {
      name: '操作',
      width: 200,
      fixed: 'right',
      thStyle: { 'text-align': 'left' },
      operateList: [
        {
          type: 'btnText',
          label: '编辑',
          id: 'early-warning-edit',
          authId: 'ecp-admin:earlyWarning:update',
          config: { type: 'text' },
          style: { color: 'rgb(219,139,57)' },
          hidden: (val) => {
            return false // !isHidden(['1'], val)
          }
        },
        {
          type: 'btnText',
          label: '删除',
          id: 'early-warning-delete',
          authId: 'ecp-admin:earlyWarning:deleteById',
          isMore: true,
          config: { type: 'text' },
          style: { color: '#ff0000' },
          hidden: (val) => {
            return false // !isHidden(['1'], val)
          }
        }
      ]
    }
  ]
}

export default {}
export { headerConfig }
